package SwingView.Quiz;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import JDBC.InstructorQuizActivities;
import JDBC.PeopleActivities;
import JDBC.StudentQuizActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsQuiz;
import SwingModel.CmsQuizSubmission;
import SwingModel.CmsStudent;

public class ALViewQuizSubmission implements ActionListener{

	private int quizID;

	public ALViewQuizSubmission(int quizID){
		this.quizID = quizID;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String courseID = CmsPresenter.user.getSelectedCourse().getCourseID();
		CmsQuiz quiz = InstructorQuizActivities.retrieveQuiz(courseID, quizID);
		List<CmsStudent> students = PeopleActivities.getListOfStudent(courseID);
		List<CmsQuizSubmission> quizSubs = new ArrayList();
		for(CmsStudent student : students){
			quizSubs.add(StudentQuizActivities.getQuizSubmission(quizID, student.getUsername()));
		}
		CmsPresenter.mainView.displayQuizSubmissionPage(quiz,quizSubs, students);
	}

	
}
